package com.business.yang.mvp.presenter.find;

import android.content.Context;
import android.view.ViewGroup;

import com.business.yang.mvp.view.find.view.IFindParentView;
import com.lyxs916.appbaselibrary.core.presenter.BasePresenter;
import com.lyxs916.common.HostType;
import com.lyxs916.network.BaseHttpRequest;
import com.lyxs916.network.HttpCallBack;

import java.io.IOException;

import okhttp3.ResponseBody;

/**
 * 说明:
 * 作者： 杨阳; 创建于：  2017-06-08  16:09
 */
public class FindPresenter extends BasePresenter<IFindParentView.IFindView> {

    public void requestHttpData(boolean first, ViewGroup viewGroup) {

        HttpCallBack.Builder buider = new HttpCallBack.Builder((Context) this.mvpView)
                .setHostType(HostType.TYPE_THREE)
                .setCancelable(true)
                .setHint("123456")
                .setmCoreOnLoadingBarListener(mvpView)
                .setShowDefeatView(true,viewGroup);


        final HttpCallBack httpCallBack = new HttpCallBack<ResponseBody>(buider) {
            @Override
            public void onSuccess(final ResponseBody result) {
                super.onSuccess(result);
                if (result != null) {
                    try {
                        mvpView.resultData(result.string().toString());
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }

            }
        };


        BaseHttpRequest.executeGet(httpCallBack, "nc/article/headline/T1348647909107/0-20.html");

    }


    public void requestHttpData2(boolean first, ViewGroup viewGroup) {

        HttpCallBack.Builder buider = new HttpCallBack.Builder((Context) this.mvpView)
                .setHostType(HostType.TYPE_THREE)
                .setCancelable(true)
                .setmCoreOnLoadingBarListener(mvpView)
                .setShowDefeatView(false,viewGroup);


        final HttpCallBack httpCallBack = new HttpCallBack<ResponseBody>(buider) {
            @Override
            public void onSuccess(final ResponseBody result) {
                super.onSuccess(result);
                if (result != null) {
                    try {
                        mvpView.resultData(result.string().toString());
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }

            }
        };

        BaseHttpRequest.executeGet(httpCallBack, "nc/article/headline/T1348647909107/0-20.html");

    }

    public void defeat(boolean first, ViewGroup viewGroup) {

        HttpCallBack.Builder buider = new HttpCallBack.Builder((Context) this.mvpView)
                .setHostType(HostType.TYPE_THREE)
                .setCancelable(true)
                .setmCoreOnLoadingBarListener(mvpView)
                .setShowDefeatView(false,viewGroup);


        final HttpCallBack httpCallBack = new HttpCallBack<ResponseBody>(buider) {
            @Override
            public void onSuccess(final ResponseBody result) {
                super.onSuccess(result);
                if (result != null) {
                    try {
                        mvpView.resultData(result.string().toString());
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }

            }
        };

        BaseHttpRequest.executeGet(httpCallBack, "nc/article/headline/T1348647909107/0-20");

    }

}
